﻿using WMS.FC.Domain.DomainObject.System;

namespace WMS.FC.Domain.Repository
{
    public interface IUnitOfWork
    {
        /// <summary>
        /// 使用事务
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="action"></param>
        /// <returns></returns>
        Task<ActionResult<List<T>>> UseTranAsync<T>(Func<Task<ActionResult<List<T>>>> action) where T : DomainObjectBase;

        /// <summary>
        /// 使用事务
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="action"></param>
        /// <returns></returns>
        Task<ActionResult<T>> UseTranAsync<T>(Func<Task<ActionResult<T>>> action) where T : DomainObjectBase;

        /// <summary>
        /// 使用事务
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        Task<ActionResult<string>> UseTranAsync(Func<Task<ActionResult<string>>> action);

        /// <summary>
        /// 使用事务
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        Task<ActionResultBase> UseTranAsync(Func<Task<ActionResultBase>> action);

        /// <summary>
        /// 开始事务
        /// </summary>
        /// <returns></returns>
        Task BeginTransactionAsync();

        /// <summary>
        /// 提交事务
        /// </summary>
        /// <returns></returns>
        Task CommitTransactionAsync();

        /// <summary>
        /// 回滚事务
        /// </summary>
        /// <returns></returns>
        Task RollbackTransactionAsync();
    }
}
